import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout.vue'
import Home from '@/views/home.vue'
// import Find from '@/views/find.vue'
// import News from '@/views/news.vue'
// import User from '@/views/user.vue'
// import CityList from '@/views/city-list.vue'
// 懒加载
const Find = () => import('@/views/find.vue')
const News = () => import('@/views/news.vue')
const User = () => import('@/views/user.vue')
const CityList = () => import('@/views/city-list.vue')
const HousesDetail = () => import('@/views/houses-detail.vue')
const Map = () => import('@/views/map.vue')
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      { path: 'home', component: Home },
      { path: 'find', component: Find },
      { path: 'news', component: News },
      { path: 'user', component: User }
    ]
  },
  { path: '/city', component: CityList },
  { path: '/housesdetail/:id', component: HousesDetail },
  { path: '/map', component: Map }
]

const router = new VueRouter({
  routes
})

export default router
